package com.jiangruan.javaproject;

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaproject.address.Address;
import com.jiangruan.javaproject.bean.HotVidCommon;
import com.jiangruan.javaproject.bean.HotVideo;
import com.jiangruan.javaproject.request.HttpUtils;
import com.jiangruan.javaproject.service.GetBsetBlockHash;
import com.jiangruan.javaproject.service.HotVideoService;
import com.jiangruan.javaproject.service.WeatherService;

import java.security.KeyPair;
import java.util.List;
import java.util.Scanner;

/**
 * @author zhongjun
 * @ClassName com.jiangruan.javaproject.Main
 * @create 2021年12月06日 20:42
 * @desc:该类是java项目的主函数的类，是程序的入口
 *
 */
public class Main {
    public static void main(String[] args) {
    run();

    }
    public static void  run(){
        System.out.println("========比特币系统设计期末考查系统");
        System.out.println("本系统已实现以下功能");
        System.out.println("1.热门视频抓取 2. 与比特币客户端通信 3.比特币地址推导 4.天气查询 0.退出");
       while (true){
           userMenu();
       }


    }
    public static void userMenu(){
        System.out.println("请输入要使用的功能序号:");
        System.out.println("1.热门视频抓取 2. 与比特币客户端通信 3.比特币地址推导 4.天气查询 0.退出");

        Scanner scanner =new Scanner(System.in);
        int num = scanner.nextInt();
        switch (num){
            case 1://热门视频抓取
                HotVideoService hotVideo =new HotVideoService();
                List<HotVideo> videoList =hotVideo.getHotVideo();
                for (HotVideo video :videoList){
                    System.out.println(video.getShare_url());
                }
                break;
            case 2://与比特币客户端通信
                GetBsetBlockHash getBsetBlockHash = new GetBsetBlockHash();
                System.out.println( getBsetBlockHash.getbestblockhash());
                break;
            case 3://比特币地址推导
                Address address = new Address();
                KeyPair keyPair = address.generateKey();
                String adddress = address.newAddress(keyPair);
                boolean b = address.validateAddr(adddress);
                System.out.println(b);
                break;
            case 4:
                //天气预报
                WeatherService weatherService = new WeatherService();
                Scanner sun = new Scanner(System.in);
                System.out.println("输入城市");
                String city = sun.next();
                System.out.println(weatherService.GetWeather(city).getResult());
                break;
            case 0://退出
                System.out.println("谢谢使用");
                System.exit(0);
                break;
            default:
                System.out.println("输入有误，重新输入");
                break;
        }

    }

}
